package com.linkage.jz.bankruptcy.activity.Project.ZQUser;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.linkage.jz.bankruptcy.BankruptcyApp;
import com.linkage.jz.bankruptcy.Consts;
import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.Main.CreateAddrActivity;
import com.linkage.jz.bankruptcy.activity.Main.TempleyActivity;
import com.linkage.jz.bankruptcy.activity.Project.ApplyProNoticeActivity;
import com.linkage.jz.bankruptcy.adapter.FullyGridLayoutManager;
import com.linkage.jz.bankruptcy.base.BaseCreateActivity;
import com.linkage.jz.bankruptcy.bean.ContactInfo;
import com.linkage.jz.bankruptcy.bean.ManagerUserInfo;
import com.linkage.jz.bankruptcy.bean.MyAddr;
import com.linkage.jz.bankruptcy.bean.TaskAtta;
import com.linkage.jz.bankruptcy.bean.ZQUserDetailBaseInfo;
import com.linkage.jz.bankruptcy.event.RefreshEvent;
import com.linkage.jz.bankruptcy.net.BaseSubscriber;
import com.linkage.jz.bankruptcy.net.Network;
import com.linkage.jz.bankruptcy.net.ToastUtil;
import com.linkage.jz.bankruptcy.utils.SPUtils;
import com.linkage.jz.bankruptcy.widget.CommonPromptDialog;
import com.linkage.jz.bankruptcy.widget.PublicNoticeDialog;
import com.linkage.seapeak.pojo.UploadImage;
import com.linkage.seapeak.view.QuickUserPopView;

import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


/**
 * @author AFAP
 * 债权人信息编辑
 */
public class EditZQUserBaseInfo_EditActivity extends BaseCreateActivity implements OnClickListener {
    private static final String TAG = EditZQUserBaseInfo_EditActivity.class.getSimpleName();
    private static final String ACTION_EDIT = "ACTION_EDIT";
    private static final String KEY_ZQUSER = "KEY_ZQUSER";
    private static final String KEY_TYPE = "KEY_TYPE";
    private TextView popClick,tv_type;
    private int REQUEST_CODE_ADDRESS = 10001;

    private String mAction = "";
    private ZQUserDetailBaseInfo mZQUserInfo;
    // TODO
    private int opType = 0; //0:发送验证, 1:暂存
    private static int mType = 1; //0管理人，1债权人
    private static int mEdittype = 0; //0新增，1修改

    private static final int TYPE_BIG_JG = 0; //  0:机构债权人,1:自然债权人,2:税务
    private static final int TYPE_BIG_ZRR = 1;
    private static final int TYPE_BIG_SW = 2;
    private static final int TYPE_SMALL_FDDBR = 0; //0:法定代表人, 1:代理人 2:本人
    private static final int TYPE_SMALL_DLR = 1;
    private static final int TYPE_SMALL_BR = 2;
    private static final int TYPE_UPLOAD = 0; // 0:线上,1:线下
    private static final int TYPE_LOCAL = 1;

    private int identityBigTypes = TYPE_BIG_JG; // 身份大类
    private int identitySmallTypes = TYPE_SMALL_FDDBR; // 身份小类

    private int provideBusinessLicense = TYPE_UPLOAD; // 营业执照提供方式
    private int provideLegalRepresentative = TYPE_UPLOAD; // 法定代表人身份证明提供方式 -- 机构、法定代表人
    private int provideCardInt = TYPE_UPLOAD; // 法定代表人身份证明提供方式-- 机构、法定代表人

    private int creditorsProvideCard = TYPE_UPLOAD; // 代理人身份证提供方式  -- 机构、代理人


    private int zqrLicense = TYPE_UPLOAD;//债权人身份证明提供方式

    private int provideCard1 = TYPE_UPLOAD; // 法定代表人身份证提供方式
    //    private int creditorsProvideCard = TYPE_UPLOAD; // 代理人身份证提供方式
    private int provideCard3 = TYPE_UPLOAD; // 本人身份证提供方式
    private String sysAddressId = ""; //邮寄地址
    private int providePowerAttorney = TYPE_UPLOAD; // 授权委托书提供方式
    private MyAddr mAddrInfo;


    // 营业执照
    private RecyclerView mImgRecyclerView_yyzz;
    private List<UploadImage> mImgList_yyzz = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_yyzz;

    // 法人身份证明文件
    private RecyclerView mImgRecyclerView_frsfzm;
    private List<UploadImage> mImgList_frsfzm = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_frsfzm;

    // 法人身份证明文件2
    // 机构-代理人也有一个这个，而且在不同的位置
    private RecyclerView mImgRecyclerView_frsfzm_zm;
    private List<UploadImage> mImgList_frsfzm_zm = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_frsfzm_zm;

    // 法人身份证明文件2
    // 机构-代理人也有一个这个，而且在不同的位置
    private RecyclerView mImgRecyclerView_frsfzm2;
    private List<UploadImage> mImgList_frsfzm2 = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_frsfzm2;

    // 法人身份证、执业证
    private RecyclerView mImgRecyclerView_frsfz;
    private List<UploadImage> mImgList_frsfz = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_frsfz;

    // 代理人身份证
    private RecyclerView mImgRecyclerView_dlr_sfz_zyz;
    private List<UploadImage> mImgList_dlr_sfz_zyz = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_dlr_sfz_zyz;

    // 代理人授权委托
    private RecyclerView mImgRecyclerView_dlr_sqwt;
    private List<UploadImage> mImgList_dlr_sqwt = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_dlr_sqwt;

    // 自然人本人
    private RecyclerView mImgRecyclerView_zrr_br_sfz;
    private List<UploadImage> mImgList_zrr_br_sfz = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_zrr_br_sfz;

    private RecyclerView mImgRecyclerView_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz;
    private List<UploadImage> mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz = new ArrayList<>();
    private GridImagesAdapter mImgAdapter_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz;


    private EditText et_zqr_name, et_zqr_base_jg_social, et_zqr_base_jg_legalname, et_zqr_fr_mobile,
            et_zqr_fr_mobile_other, et_zqr_fr_email, et_zqr_fr_cardnum,
            et_zqr_fr_bank, et_zqr_fr_bankBranch, et_zqr_fr_bankAccountName, et_zqr_fr_bankAccount,

    et_zqr_dlr_name, et_zqr_dlr_mobile, et_zqr_dlr_mobile_other, et_zqr_dlr_email, et_zqr_dlr_sfz_zyz,
            et_zqr_zrr_br_mobile, et_zqr_zrr_br_mobile_other, et_zqr_zrr_br_email, et_zqr_zrr_br_card, zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card;
    private TextView tv_zqr_address, proxy_show_temp_xts, show_sfzm_temp1, show_sfzm_temp2;

    private View area_zqr_type, area_zqr_type_small, include_zqr_base_group,
            include_zqr_legal_person, include_zqr_dlr,
            include_zqr_zrr_br, zrr_zqrheadinfo, ll_zqr_frsfzm;

    //    private static String mProID;
//    public static void start(Context context,MyProInfo info) {
//        Intent intent = new Intent(context, CreateProFlowActivity.class);
//        mInfo = info;
//        context.startActivity(intent);
//    }
    CommonPromptDialog mPromptDialog;

    private static Boolean getDataFlag = false;

    public static void start(Context context, ZQUserDetailBaseInfo info, int cType, int edittype, Boolean flag) {
        Intent intent = new Intent(context, EditZQUserBaseInfo_EditActivity.class);
        intent.putExtra(KEY_ZQUSER, info);
        intent.putExtra(KEY_TYPE, cType);
        mEdittype = edittype;
        getDataFlag = flag;
        context.startActivity(intent);
    }


    public static void start(Context context, ZQUserDetailBaseInfo info, int cType, int edittype) {
        Intent intent = new Intent(context, EditZQUserBaseInfo_EditActivity.class);
        intent.putExtra(KEY_ZQUSER, info);
        intent.putExtra(KEY_TYPE, cType);
        mEdittype = edittype;
        context.startActivity(intent);
    }

    @Override
    public void setListener() {
    }

    @Override
    public void initTitle() {
    }

    @Override
    public void initView() {
    }

    @Override
    public void initData() {
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_edit_zqbase_user);
        super.onCreate(savedInstanceState);
        titlebar_title.setText("修改基础信息");
        findViewById(R.id.ll_edit).setVisibility(View.VISIBLE);
        tv_type = findViewById(R.id.tv_type);
        tv_type.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                AlertDialog.Builder builder = new AlertDialog.Builder(EditZQUserBaseInfo_EditActivity.this);
                builder.setTitle("请选择类型");
                final String[] strTypes = getResources().getStringArray(R.array.type_zq);
                builder.setItems(R.array.type_zq, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which)
                        {
                            case 0:
                                identityBigTypes = TYPE_BIG_JG;
                                identitySmallTypes = TYPE_SMALL_FDDBR;
                                break;
                            case 1:
                                identityBigTypes = TYPE_BIG_JG;
                                identitySmallTypes = TYPE_SMALL_DLR;
                                break;
                            case 2:
                                identityBigTypes = TYPE_BIG_ZRR;
                                identitySmallTypes = TYPE_SMALL_BR;
                                break;
                            case 3:
                                identityBigTypes = TYPE_BIG_ZRR;
                                identitySmallTypes = TYPE_SMALL_DLR;
                                break;
                            case 4:
                                identityBigTypes = TYPE_BIG_SW;
                                break;
                        }
                        showStatus();
                    }
                });
                builder.show();
            }
        });

        mZQUserInfo = (ZQUserDetailBaseInfo) getIntent().getSerializableExtra(KEY_ZQUSER);
        mType = getIntent().getIntExtra(KEY_TYPE, 0);
        // 如果有了大类了，就认为是已经有了，进来编辑的
        if (mZQUserInfo.getIdentityBigTypes() != null) {
            mAction = ACTION_EDIT;
            titlebar_title.setText("修改基础信息");
        }


        initViews();

        if (1 == mType) {
            titlebar_title.setText("修改基础信息");
            titlebar_menu_text.setText("提交");
        } else {
            titlebar_menu_text.setText("提交 ");
        }
        showTitle();
        titlebar_menu_text.setOnClickListener(this);

        mPromptDialog = new CommonPromptDialog(this, CommonPromptDialog.TYPE_TIPS);
        mPromptDialog.setContent("该操作须取得债权人授权或依据文件");
        mPromptDialog.setPositiveClickListener("已取得", view -> mPromptDialog.dismiss());
        mPromptDialog.setmCloseListener(v -> {
            mPromptDialog.dismiss();
            finish();
        });
        mPromptDialog.setNegativeClickListener("暂未取得", view -> {
            mPromptDialog.dismiss();
            finish();
        });
        if (mType == 0) {
            mPromptDialog.show();
        }

        if (getDataFlag) {
            getData();
        }
    }


    //     mType = 1; //0管理人，1债权人
//     mEdittype = 0; //0新增，1修改
    private void showTitle() {
        popClick = findViewById(R.id.pop_click);
        if (mType == 0) {
            findViewById(R.id.titlebar_menu_text_zancun).setVisibility(View.INVISIBLE);
            findViewById(R.id.zqr_legal_ll_bank).setVisibility(View.VISIBLE);
//            findViewById(R.id.zqr_ll_bank).setVisibility(View.VISIBLE);

//            titlebar_menu_text_zancun
            popClick.setVisibility(View.GONE);
        } else {
            findViewById(R.id.titlebar_menu_text_zancun).setVisibility(View.INVISIBLE);
            findViewById(R.id.zqr_legal_ll_bank).setVisibility(View.GONE);
//            findViewById(R.id.zqr_ll_bank).setVisibility(View.GONE);

/**
 * 弹窗
 */
            popClick.setVisibility(View.VISIBLE);
            popClick.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    //等参数
                    getProjetContact();
//                    QuickUserPopView.show(EditZQUserBaseInfo_EditActivity.this, BankruptcyApp.mUserid,
//                            mZQUserInfo.getBankruptcyProjectId(), BankruptcyApp.mUsername, BankruptcyApp.mphone);
                }
            });
        }

        if (mType == 1 && (mEdittype == 0 || mEdittype == 1)) {
            titlebar_title.setText("填写基础信息");
        }
        if (mType == 0 && mEdittype == 0) {
            titlebar_title.setText("录入债权人基础信息");
        }
        if (mType == 0 && mEdittype == 1) {
            titlebar_title.setText("录入债权人基础信息");
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && data != null) {
            if (requestCode == REQUEST_CODE_ADDRESS) {
                sysAddressId = data.getStringExtra("id");
                tv_zqr_address.setText(data.getStringExtra("desc"));
                mAddrInfo = (MyAddr) data.getSerializableExtra("bean");
                if(mAddrInfo!=null)
                    mZQUserInfo.setAddressInfo( new MyAddr().toArrInfo(mAddrInfo));
            }
        }
    }

    private void initViews() {

        titlebar_back = findViewById(R.id.titlebar_back);
        titlebar_menu_text = findViewById(R.id.titlebar_menu_text);
        titlebar_back.setOnClickListener(this);
        titlebar_menu_text.setText("提交");
        titlebar_menu_text.setVisibility(View.VISIBLE);
        show_sfzm_temp1 = findViewById(R.id.show_sfzm_temp1);
        show_sfzm_temp1.setOnClickListener(this);

        show_sfzm_temp2 = findViewById(R.id.show_sfzm_temp2);
        show_sfzm_temp2.setOnClickListener(this);

        et_zqr_name = findViewById(R.id.et_zqr_name);
        area_zqr_type = findViewById(R.id.area_zqr_type);
        area_zqr_type_small = findViewById(R.id.area_zqr_type_small);

        include_zqr_base_group = findViewById(R.id.include_zqr_base_group);
        include_zqr_legal_person = findViewById(R.id.include_zqr_legal_person);
        include_zqr_dlr = findViewById(R.id.include_zqr_dlr);
        include_zqr_zrr_br = findViewById(R.id.include_zqr_zrr_br);
        zrr_zqrheadinfo = findViewById(R.id.zrr_zqrheadinfo);

        ll_zqr_frsfzm = findViewById(R.id.ll_zqr_frsfzm);
        et_zqr_base_jg_social = findViewById(R.id.et_zqr_base_jg_social);

        zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card = findViewById(R.id.zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card);
        et_zqr_base_jg_legalname = findViewById(R.id.et_zqr_base_jg_legalname);
        et_zqr_fr_mobile = findViewById(R.id.et_zqr_fr_mobile);
        et_zqr_fr_mobile_other = findViewById(R.id.et_zqr_fr_mobile_other);
        et_zqr_fr_email = findViewById(R.id.et_zqr_fr_email);
        et_zqr_fr_cardnum = findViewById(R.id.et_zqr_fr_cardnum);
        et_zqr_fr_bank = findViewById(R.id.et_zqr_fr_bank_new);
        et_zqr_fr_bankBranch = findViewById(R.id.et_zqr_fr_bankBranch_new);
        et_zqr_fr_bankAccountName = findViewById(R.id.et_zqr_fr_bankAccountName_new);
        et_zqr_fr_bankAccount = findViewById(R.id.et_zqr_fr_bankAccount_new);

        proxy_show_temp_xts = findViewById(R.id.proxy_show_temp_xts);
        proxy_show_temp_xts.setOnClickListener(this);
//        et_zqr_proxy_bankBranch = findViewById(R.id.et_zqr_proxy_bankBranch);
//        et_zqr_proxy_bankAccountName = findViewById(R.id.et_zqr_proxy_bankAccountName);
//        et_zqr_proxy_bankAccount = findViewById(R.id.et_zqr_proxy_bankAccount);


        et_zqr_dlr_name = findViewById(R.id.et_zqr_dlr_name);
        et_zqr_dlr_mobile = findViewById(R.id.et_zqr_dlr_mobile);
        et_zqr_dlr_mobile_other = findViewById(R.id.et_zqr_dlr_mobile_other);
        et_zqr_dlr_email = findViewById(R.id.et_zqr_dlr_email);
        et_zqr_dlr_sfz_zyz = findViewById(R.id.et_zqr_dlr_sfz_zyz);

        et_zqr_zrr_br_mobile = findViewById(R.id.et_zqr_zrr_br_mobile);
        et_zqr_zrr_br_mobile_other = findViewById(R.id.et_zqr_zrr_br_mobile_other);
        et_zqr_zrr_br_email = findViewById(R.id.et_zqr_zrr_br_email);
        et_zqr_zrr_br_card = findViewById(R.id.et_zqr_zrr_br_card);
        tv_zqr_address = findViewById(R.id.tv_zqr_address);

        mImgRecyclerView_yyzz = findViewById(R.id.recycler_imgs_yyzz);
        mImgRecyclerView_yyzz.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false));
        mImgAdapter_yyzz = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_yyzz.setList(mImgList_yyzz);
        mImgAdapter_yyzz.setSelectMax(1);
        mImgRecyclerView_yyzz.setAdapter(mImgAdapter_yyzz);

//        mImgRecyclerView_frsfzm = findViewById(R.id.recycler_imgs_frsfzm);
//        mImgRecyclerView_frsfzm.setLayoutManager(new FullyGridLayoutManager(this, 3, GridLayoutManager.VERTICAL,
//                false));
//        mImgAdapter_frsfzm = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
//        mImgAdapter_frsfzm.setList(mImgList_frsfzm);
//        mImgRecyclerView_frsfzm.setAdapter(mImgAdapter_frsfzm);


        mImgRecyclerView_frsfzm2 = findViewById(R.id.recycler_imgs_frsfzm);
        mImgRecyclerView_frsfzm2.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_frsfzm2 = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_frsfzm2.setList(mImgList_frsfzm2);
        mImgRecyclerView_frsfzm2.setAdapter(mImgAdapter_frsfzm2);


//        mImgRecyclerView_frsfzm = findViewById(R.id.recycler_imgs_frsfzm);
//        mImgRecyclerView_frsfzm.setLayoutManager(new FullyGridLayoutManager(this, 3, GridLayoutManager.VERTICAL,
//                false));
//        mImgAdapter_frsfzm = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
//        mImgAdapter_frsfzm.setList(mImgList_frsfzm);
//        mImgRecyclerView_frsfzm.setAdapter(mImgAdapter_frsfzm);

        mImgRecyclerView_frsfzm_zm = findViewById(R.id.recycler_imgs_frsfz_zm);
        mImgRecyclerView_frsfzm_zm.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_frsfzm_zm = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_frsfzm_zm.setList(mImgList_frsfzm_zm);
        mImgRecyclerView_frsfzm_zm.setAdapter(mImgAdapter_frsfzm_zm);


        mImgRecyclerView_frsfz = findViewById(R.id.recycler_imgs_frsfz);
        mImgRecyclerView_frsfz.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL, false));
        mImgAdapter_frsfz = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_frsfz.setList(mImgList_frsfz);
        mImgRecyclerView_frsfz.setAdapter(mImgAdapter_frsfz);

        mImgRecyclerView_dlr_sfz_zyz = findViewById(R.id.recycler_imgs_dlr_sfz_zyz);
        mImgRecyclerView_dlr_sfz_zyz.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_dlr_sfz_zyz = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_dlr_sfz_zyz.setList(mImgList_dlr_sfz_zyz);
        mImgRecyclerView_dlr_sfz_zyz.setAdapter(mImgAdapter_dlr_sfz_zyz);

        mImgRecyclerView_dlr_sqwt = findViewById(R.id.recycler_imgs_dlr_sqwt);
        mImgRecyclerView_dlr_sqwt.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_dlr_sqwt = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_dlr_sqwt.setList(mImgList_dlr_sqwt);
        mImgRecyclerView_dlr_sqwt.setAdapter(mImgAdapter_dlr_sqwt);

        mImgRecyclerView_zrr_br_sfz = findViewById(R.id.recycler_imgs_zrr_br_sfz);
        mImgRecyclerView_zrr_br_sfz.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_zrr_br_sfz = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_zrr_br_sfz.setList(mImgList_zrr_br_sfz);
        mImgRecyclerView_zrr_br_sfz.setAdapter(mImgAdapter_zrr_br_sfz);


        mImgRecyclerView_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz = findViewById(R.id.zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz);
        mImgRecyclerView_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.setLayoutManager(new FullyGridLayoutManager(this, 4, GridLayoutManager.VERTICAL,
                false));
        mImgAdapter_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz = new BaseCreateActivity.GridImagesAdapter(this, TYPE_EDIT);
        mImgAdapter_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.setList(mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz);
        mImgRecyclerView_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.setAdapter(mImgAdapter_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz);

        // 大类型
        ((RadioGroup) findViewById(R.id.rg_zqr_sf_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_sf_type_1) {
                identityBigTypes = TYPE_BIG_JG;

                findViewById(R.id.rg_zqr_czr_type_1).setVisibility(View.VISIBLE);
                findViewById(R.id.rg_zqr_czr_type_3).setVisibility(View.GONE);

                ((RadioButton) findViewById(R.id.rg_zqr_czr_type_1)).setChecked(true);
                identitySmallTypes = TYPE_SMALL_FDDBR;

            } else if (which == R.id.rg_zqr_sf_type_2) {
                identityBigTypes = TYPE_BIG_ZRR;
                findViewById(R.id.rg_zqr_czr_type_1).setVisibility(View.GONE);
                findViewById(R.id.rg_zqr_czr_type_3).setVisibility(View.VISIBLE);
                ((RadioButton) findViewById(R.id.rg_zqr_czr_type_3)).setChecked(true);
                identitySmallTypes = TYPE_SMALL_BR;
            } else if (which == R.id.rg_zqr_sf_type_3) {
                identityBigTypes = TYPE_BIG_SW;
            }

            showStatus();
        });


        // 小类型
        ((RadioGroup) findViewById(R.id.rg_zqr_czr_type)).setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int which) {
                if (which == R.id.rg_zqr_czr_type_1) {
                    identitySmallTypes = TYPE_SMALL_FDDBR;
                } else if (which == R.id.rg_zqr_czr_type_2) {

                    identitySmallTypes = TYPE_SMALL_DLR;
                } else if (which == R.id.rg_zqr_czr_type_3) {
                    identitySmallTypes = TYPE_SMALL_BR;
                }
                showStatus();
            }
        });
        area_zqr_type.setVisibility(View.GONE);
        // 营业执照提供方式
        ((RadioGroup) findViewById(R.id.rg_zqr_yyzz_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_yyzz_type_1) {
                provideBusinessLicense = TYPE_UPLOAD;
                findViewById(R.id.area_upload_yyzz).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_yyzz_type_2) {
                provideBusinessLicense = TYPE_LOCAL;
                findViewById(R.id.area_upload_yyzz).setVisibility(View.GONE);
            }
        });

        // 债权人身份证明方式
        ((RadioGroup) findViewById(R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type_1) {
                zqrLicense = TYPE_UPLOAD;
                findViewById(R.id.zrr_zqrheadinfo_area_upload_zrr_br_sfz).setVisibility(View.VISIBLE);
            } else if (which == R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type_2) {
                zqrLicense = TYPE_LOCAL;
                findViewById(R.id.zrr_zqrheadinfo_area_upload_zrr_br_sfz).setVisibility(View.GONE);
            }
        });


        // 法人身份证明
        ((RadioGroup) findViewById(R.id.rg_zqr_frsfz_type_zm)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_frsfz_type_zm_1) {
                provideCardInt = TYPE_UPLOAD;
                findViewById(R.id.recycler_imgs_frsfz_zm).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_frsfz_type_zm_2) {
                provideCardInt = TYPE_LOCAL;
                findViewById(R.id.recycler_imgs_frsfz_zm).setVisibility(View.GONE);
            }
        });

        // 法人身份证
        ((RadioGroup) findViewById(R.id.rg_zqr_frsfz_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_frsfz_type_1) {
                provideCard1 = TYPE_UPLOAD;
                findViewById(R.id.area_upload_frsfz).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_frsfz_type_2) {
                provideCard1 = TYPE_LOCAL;
                findViewById(R.id.area_upload_frsfz).setVisibility(View.GONE);
            }
        });


        // 法人身份证
        ((RadioGroup) findViewById(R.id.rg_zqr_frsfzm2_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_frsfzm2_type_1) {
                provideCard1 = TYPE_UPLOAD;
                findViewById(R.id.area_upload_frsfzm).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_frsfzm2_type_2) {
                provideCard1 = TYPE_LOCAL;
                findViewById(R.id.area_upload_frsfzm).setVisibility(View.GONE);
            }
        });


        // 代理人身份证执业证
        ((RadioGroup) findViewById(R.id.rg_zqr_dlr_sfz_zyz_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_dlr_sfz_zyz_type_1) {
                creditorsProvideCard = TYPE_UPLOAD;
                findViewById(R.id.area_upload_dlr_sfz_zyz).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_dlr_sfz_zyz_type_2) {
                creditorsProvideCard = TYPE_LOCAL;
                findViewById(R.id.area_upload_dlr_sfz_zyz).setVisibility(View.GONE);
            }
        });

        // 代理人授权委托
        ((RadioGroup) findViewById(R.id.rg_zqr_dlr_sqwt_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_dlr_sqwt_type_1) {
                providePowerAttorney = TYPE_UPLOAD;
                findViewById(R.id.area_upload_dlr_sqwt).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_dlr_sqwt_type_2) {
                providePowerAttorney = TYPE_LOCAL;
                findViewById(R.id.area_upload_dlr_sqwt).setVisibility(View.GONE);
            }
        });

        // 本人身份证
        ((RadioGroup) findViewById(R.id.rg_zqr_zrr_br_sfz_type)).setOnCheckedChangeListener((radioGroup, which) -> {
            if (which == R.id.rg_zqr_zrr_br_sfz_type_1) {
                provideCard3 = TYPE_UPLOAD;
                findViewById(R.id.area_upload_zrr_br_sfz).setVisibility(View.VISIBLE);
            } else if (which == R.id.rg_zqr_zrr_br_sfz_type_2) {
                provideCard3 = TYPE_LOCAL;
                findViewById(R.id.area_upload_zrr_br_sfz).setVisibility(View.GONE);
            }
        });
        showStatus();
//        et_zqr_name.setText(mZQUserInfo.getCreditorName());
//        et_zqr_fr_mobile.setText(mZQUserInfo.getContact());
//        et_zqr_dlr_mobile.setText(mZQUserInfo.getContact());
//        et_zqr_zrr_br_mobile.setText(mZQUserInfo.getContact());

        if (TextUtils.equals(mAction, ACTION_EDIT)) {
            // 大小类型隐藏
            if (mEdittype == 0) {
                area_zqr_type.setVisibility(View.GONE);
            }

            if (mZQUserInfo.getIdentityBigTypes() != null) {
                int bigType = Integer.parseInt(mZQUserInfo.getIdentityBigTypes().getValue());
                if (bigType == TYPE_BIG_JG) {
                    findViewById(R.id.rg_zqr_sf_type_1).performClick();
                } else if (bigType == TYPE_BIG_ZRR) {
                    findViewById(R.id.rg_zqr_sf_type_2).performClick();
                } else if (bigType == TYPE_BIG_SW) {
                    findViewById(R.id.rg_zqr_sf_type_3).performClick();
                }

                if (bigType == TYPE_BIG_SW) {
                    findViewById(R.id.rg_zqr_czr_type_2).performClick();
                } else {
                    if (mZQUserInfo.getIdentitySmallTypes() != null) {
                        int smallType = Integer.parseInt(mZQUserInfo.getIdentitySmallTypes().getValue());
                        if (smallType == TYPE_SMALL_FDDBR) {
                            findViewById(R.id.rg_zqr_czr_type_1).performClick();
                        } else if (smallType == TYPE_SMALL_DLR) {
                            findViewById(R.id.rg_zqr_czr_type_2).performClick();
                        } else if (smallType == TYPE_SMALL_BR) {
                            findViewById(R.id.rg_zqr_czr_type_3).performClick();
                        }
                    }
                }


            }
            et_zqr_name.setText(mZQUserInfo.getCreditorName());
            et_zqr_base_jg_social.setText(mZQUserInfo.getSocialUniformCreditCode());
            et_zqr_base_jg_legalname.setText(mZQUserInfo.getLegalRepresentativeName());
            et_zqr_dlr_name.setText(mZQUserInfo.getAgentName());
            if (!TextUtils.isEmpty(mZQUserInfo.getAgentLicenseNumber())) {
                et_zqr_dlr_sfz_zyz.setText(mZQUserInfo.getAgentLicenseNumber());
            } else {
                et_zqr_dlr_sfz_zyz.setText(mZQUserInfo.getCreditorsIDCardNumber());
            }
            et_zqr_fr_bank.setText(mZQUserInfo.getBank());
            et_zqr_fr_bankBranch.setText(mZQUserInfo.getBankBranch());
            et_zqr_fr_bankAccountName.setText(mZQUserInfo.getBankAccountName());
            et_zqr_fr_bankAccount.setText(mZQUserInfo.getBankAccount());


            JSONArray provideCardJson = new JSONArray();//身份证附件
            JSONArray providePowerAttorneyJson = new JSONArray();//授权委托书附件
            JSONArray creditorsProvideCardJson = new JSONArray();
            if(mZQUserInfo.getAddressInfo()!=null) {
                tv_zqr_address.setText(mZQUserInfo.getAddressInfo().getDetailString());
                sysAddressId = mZQUserInfo.getAddressInfo().getId();
                mAddrInfo= new MyAddr().toMyArr(mZQUserInfo.getAddressInfo());
            }

            // 机构-法人组合
            if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_FDDBR) {
                et_zqr_fr_cardnum.setText(mZQUserInfo.getCardNumber());
                et_zqr_fr_email.setText(mZQUserInfo.getEmail());
                et_zqr_fr_mobile_other.setText(mZQUserInfo.getOtherContact());

                ll_zqr_frsfzm.setVisibility(View.GONE);

                if(identitySmallTypes == TYPE_SMALL_DLR)
                {
                    ll_zqr_frsfzm.setVisibility(View.VISIBLE);
                }
                JSONArray provideBusinessLicenseJson = new JSONArray();//营业执照附件
                JSONArray provideLegalRepresentativeJson = new JSONArray();//法定代表人身份证明附件

                if(mZQUserInfo.getProvideBusinessLicense() != null) {
                    provideBusinessLicense = Integer.parseInt(mZQUserInfo.getProvideBusinessLicense().getValue());
                    if (provideBusinessLicense == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_yyzz_type_1).performClick();

                        // TODO 带入附件
                    } else {
                        findViewById(R.id.rg_zqr_yyzz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_yyzz_type_2).performClick();
                }


                if (mZQUserInfo.getProvideBusinessLicenseAttas() != null) {
                    for (TaskAtta atta : mZQUserInfo.getProvideBusinessLicenseAttas()) {
                        mImgList_yyzz.add(atta2img(atta));
                    }
                }

                //法定代表人身份证明
                if (mZQUserInfo.getProvideLegalRepresentativeAttas() != null) {
                    for (TaskAtta atta : mZQUserInfo.getProvideLegalRepresentativeAttas()) {
                        mImgList_frsfzm_zm.add(atta2img(atta));
                    }
                }


//                    } else {
//                        findViewById(R.id.rg_zqr_frsfzm_type_2).performClick();
//                    }
//                }else{
//                    findViewById(R.id.rg_zqr_frsfzm_type_2).performClick();
//                }

                //法定代表人身份证
                if(mZQUserInfo.getProvideCard() !=null) {
                    int provideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
                    if (provideCard == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_frsfz_type_1).performClick();
                        if (mZQUserInfo.getProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvideCardAttas()) {
                                mImgList_frsfz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_frsfz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_frsfz_type_2).performClick();
                }


            } else if(identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_DLR)
            {

                et_zqr_dlr_email.setText(mZQUserInfo.getEmail());
                et_zqr_dlr_mobile_other.setText(mZQUserInfo.getOtherContact());


                if(mZQUserInfo.getCreditorsProvideCard()!=null ) {
                    creditorsProvideCard = Integer.parseInt(mZQUserInfo.getCreditorsProvideCard().getValue());
                    if (creditorsProvideCard == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_1).performClick();
                        if (mZQUserInfo.getCreditorsProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getCreditorsProvideCardAttas()) {
                                mImgList_dlr_sfz_zyz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                }
                if(mZQUserInfo.getProvidePowerAttorney()!=null ) {
                    providePowerAttorney = Integer.parseInt(mZQUserInfo.getProvidePowerAttorney().getValue());
                    if (providePowerAttorney == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_1).performClick();
                        // TODO 带入附件
                        if (mZQUserInfo.getProvidePowerAttorneyAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvidePowerAttorneyAttas()) {
                                mImgList_dlr_sqwt.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                }
                //营业执照attachmentYYZZList

                if (mZQUserInfo.getProvideBusinessLicenseAttas() != null) {
                    for (TaskAtta atta : mZQUserInfo.getProvideBusinessLicenseAttas()) {
                        mImgList_yyzz.add(atta2img(atta));
                    }
                }
                //法定代表人身份证明

                if (mZQUserInfo.getProvideLegalRepresentativeAttas() != null) {
                    for (TaskAtta atta : mZQUserInfo.getProvideLegalRepresentativeAttas()) {
                        mImgList_frsfzm2.add(atta2img(atta));
                    }
                }
            }
            else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_BR) { // 自然人-本人组合
                et_zqr_zrr_br_card.setText(mZQUserInfo.getCardNumber());
                et_zqr_zrr_br_email.setText(mZQUserInfo.getEmail());
                et_zqr_zrr_br_mobile_other.setText(mZQUserInfo.getOtherContact());

                if(mZQUserInfo.getProvideCard() != null)
                {
                    int provideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
                    if (provideCard == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_zrr_br_sfz_type_1).performClick();
                        if (mZQUserInfo.getProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvideCardAttas()) {
                                mImgList_zrr_br_sfz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_zrr_br_sfz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_zrr_br_sfz_type_2).performClick();
                }



            }  else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_DLR) //本人代理人
            {


                zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card.setText(mZQUserInfo.getCardNumber());
                et_zqr_dlr_email.setText(mZQUserInfo.getEmail());
                et_zqr_dlr_mobile_other.setText(mZQUserInfo.getOtherContact());


                if(mZQUserInfo.getProvideCardAttas()!=null ) {
                    creditorsProvideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
                    if (zqrLicense == TYPE_UPLOAD) {
                        findViewById(R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type_1).performClick();
                        if (mZQUserInfo.getCreditorsProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getCreditorsProvideCardAttas()) {
                                mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.zrr_zqrheadinfo_rg_zqr_zrr_br_sfz_type_2).performClick();
                }




                if(mZQUserInfo.getProvideCard()!=null ) {
                    creditorsProvideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
                    if (creditorsProvideCard == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_1).performClick();
                        if (mZQUserInfo.getProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvideCardAttas()) {
                                mImgList_dlr_sfz_zyz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                }
                if(mZQUserInfo.getProvidePowerAttorney()!=null ) {
                    providePowerAttorney = Integer.parseInt(mZQUserInfo.getProvidePowerAttorney().getValue());
                    if (providePowerAttorney == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_1).performClick();
                        // TODO 带入附件
                        if (mZQUserInfo.getProvidePowerAttorneyAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvidePowerAttorneyAttas()) {
                                mImgList_dlr_sqwt.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                }
            } else if (identitySmallTypes == TYPE_SMALL_DLR)
            { //  X-代理人组合
                et_zqr_dlr_email.setText(mZQUserInfo.getEmail());
                et_zqr_dlr_mobile_other.setText(mZQUserInfo.getOtherContact());


                if(mZQUserInfo.getCreditorsProvideCard()!=null ) {
                    creditorsProvideCard = Integer.parseInt(mZQUserInfo.getCreditorsProvideCard().getValue());
                    if (creditorsProvideCard == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_1).performClick();
                        if (mZQUserInfo.getCreditorsProvideCardAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getCreditorsProvideCardAttas()) {
                                mImgList_dlr_sfz_zyz.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
                }
                if(mZQUserInfo.getProvidePowerAttorney()!=null ) {
                    providePowerAttorney = Integer.parseInt(mZQUserInfo.getProvidePowerAttorney().getValue());
                    if (providePowerAttorney == TYPE_UPLOAD) {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_1).performClick();
                        // TODO 带入附件
                        if (mZQUserInfo.getProvidePowerAttorneyAttas() != null) {
                            for (TaskAtta atta : mZQUserInfo.getProvidePowerAttorneyAttas()) {
                                mImgList_dlr_sqwt.add(atta2img(atta));
                            }
                        }
                    } else {
                        findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                    }
                }else{
                    findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
                }
            }
            // 机构-法人组合
//            if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_FDDBR) {
//                et_zqr_fr_cardnum.setText(mZQUserInfo.getCardNumber());
//                et_zqr_fr_email.setText(mZQUserInfo.getEmail());
//                et_zqr_fr_mobile_other.setText(mZQUserInfo.getOtherContact());
//
//                ll_zqr_frsfzm.setVisibility(View.GONE);
//
//                if (identitySmallTypes == TYPE_SMALL_DLR) {
//                    ll_zqr_frsfzm.setVisibility(View.VISIBLE);
//                }
//                JSONArray provideBusinessLicenseJson = new JSONArray();//营业执照附件
//                JSONArray provideLegalRepresentativeJson = new JSONArray();//法定代表人身份证明附件
//
//                if (mZQUserInfo.getProvideBusinessLicense() != null) {
//                    provideBusinessLicense = Integer.parseInt(mZQUserInfo.getProvideBusinessLicense().getValue());
//                    if (provideBusinessLicense == TYPE_UPLOAD) {
//                        findViewById(R.id.rg_zqr_yyzz_type_1).performClick();
//
//                        // TODO 带入附件
////                    for (UploadImage img : mZQUserInfo.getProvideBusinessLicense()) {
////                        JSONObject obj = new JSONObject();
////                        try {
////                            obj.putOpt("attachmentName", img.getFilename());
////                            obj.putOpt("attachmentDownloadAddress", img.getFilepath());
////                            obj.putOpt("attachmentSize", img.getFilesize());
////                            provideBusinessLicenseJson.put(obj);
////                        } catch (JSONException e) {
////                            e.printStackTrace();
////                        }
////                    }
//
//                    } else {
//                        findViewById(R.id.rg_zqr_yyzz_type_2).performClick();
//                    }
//                } else {
//                    findViewById(R.id.rg_zqr_yyzz_type_2).performClick();
//                }
//
////                if(mZQUserInfo.getProvideLegalRepresentative()!=null) {
////                    provideLegalRepresentative = Integer.parseInt(mZQUserInfo.getProvideLegalRepresentative().getValue());
////                    if (provideLegalRepresentative == TYPE_UPLOAD) {
////                        findViewById(R.id.rg_zqr_frsfzm_type_1).performClick();
////                        if (mZQUserInfo.getProvideLegalRepresentativeAttas() != null) {
////                            for (TaskAtta atta : mZQUserInfo.getProvideLegalRepresentativeAttas()) {
////                                mImgList_frsfzm.add(atta2img(atta));
////                            }
////                        }
////                    } else {
////                        findViewById(R.id.rg_zqr_frsfzm_type_2).performClick();
////                    }
////                }else{
////                    findViewById(R.id.rg_zqr_frsfzm_type_2).performClick();
////                }
//
//                if (mZQUserInfo.getProvideCard() != null) {
//                    int provideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
//                    if (provideCard == TYPE_UPLOAD) {
//                        findViewById(R.id.rg_zqr_frsfz_type_1).performClick();
//                        if (mZQUserInfo.getProvideCardAttas() != null) {
//                            for (TaskAtta atta : mZQUserInfo.getProvideCardAttas()) {
//                                mImgList_frsfz.add(atta2img(atta));
//                            }
//                        }
//                    } else {
//                        findViewById(R.id.rg_zqr_frsfz_type_2).performClick();
//                    }
//                } else {
//                    findViewById(R.id.rg_zqr_frsfz_type_2).performClick();
//                }
//
//            } else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_BR)
//            { // 自然人-本人组合
//                et_zqr_zrr_br_card.setText(mZQUserInfo.getCardNumber());
//                et_zqr_zrr_br_email.setText(mZQUserInfo.getEmail());
//                et_zqr_zrr_br_mobile_other.setText(mZQUserInfo.getOtherContact());
//
//                if (mZQUserInfo.getProvideCard() != null) {
//                    int provideCard = Integer.parseInt(mZQUserInfo.getProvideCard().getValue());
//                    if (provideCard == TYPE_UPLOAD) {
//                        findViewById(R.id.rg_zqr_zrr_br_sfz_type_1).performClick();
//                        if (mZQUserInfo.getProvideCardAttas() != null) {
//                            for (TaskAtta atta : mZQUserInfo.getProvideCardAttas()) {
//                                mImgList_zrr_br_sfz.add(atta2img(atta));
//                            }
//                        }
//                    } else {
//                        findViewById(R.id.rg_zqr_zrr_br_sfz_type_2).performClick();
//                    }
//                } else {
//                    findViewById(R.id.rg_zqr_zrr_br_sfz_type_2).performClick();
//                }
//            } else if (identitySmallTypes == TYPE_SMALL_DLR)
//            { //  X-代理人组合
//                et_zqr_dlr_email.setText(mZQUserInfo.getEmail());
//                et_zqr_dlr_mobile_other.setText(mZQUserInfo.getOtherContact());
//
//
//                if (mZQUserInfo.getCreditorsProvideCard() != null) {
//                    creditorsProvideCard = Integer.parseInt(mZQUserInfo.getCreditorsProvideCard().getValue());
//                    if (creditorsProvideCard == TYPE_UPLOAD) {
//                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_1).performClick();
//                        if (mZQUserInfo.getCreditorsProvideCardAttas() != null) {
//                            for (TaskAtta atta : mZQUserInfo.getCreditorsProvideCardAttas()) {
//                                mImgList_dlr_sfz_zyz.add(atta2img(atta));
//                            }
//                        }
//                    } else {
//                        findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
//                    }
//                } else {
//                    findViewById(R.id.rg_zqr_dlr_sfz_zyz_type_2).performClick();
//                }
//                if (mZQUserInfo.getProvidePowerAttorney() != null) {
//                    providePowerAttorney = Integer.parseInt(mZQUserInfo.getProvidePowerAttorney().getValue());
//                    if (providePowerAttorney == TYPE_UPLOAD) {
//                        findViewById(R.id.rg_zqr_dlr_sqwt_type_1).performClick();
//                        // TODO 带入附件
//                        if (mZQUserInfo.getProvidePowerAttorneyAttas() != null) {
//                            for (TaskAtta atta : mZQUserInfo.getProvidePowerAttorneyAttas()) {
//                                mImgList_dlr_sqwt.add(atta2img(atta));
//                            }
//                        }
//                    } else {
//                        findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
//                    }
//                } else {
//                    findViewById(R.id.rg_zqr_dlr_sqwt_type_2).performClick();
//                }
//            }
        }
    }

    private UploadImage atta2img(TaskAtta atta) {
        UploadImage image = new UploadImage();
        image.setFilename(atta.getAttachmentName());
        image.setFilepath(atta.getAttachmentDownloadAddress());
        image.setFilesize(atta.getAttachmentSize());
        image.setLoadUrl(atta.getAttachmentPreviewAddress());
        return image;
    }

    private void showStatus() {
        area_zqr_type_small.setVisibility(View.VISIBLE);
        include_zqr_base_group.setVisibility(View.GONE);
        include_zqr_legal_person.setVisibility(View.GONE);
        include_zqr_dlr.setVisibility(View.GONE);
        include_zqr_zrr_br.setVisibility(View.GONE);

        zrr_zqrheadinfo.setVisibility(View.GONE);
        if (mType == 0) {
            findViewById(R.id.zqr_legal_ll_bank).setVisibility(View.VISIBLE);
//            findViewById(R.id.zqr_ll_bank).setVisibility(View.VISIBLE);
        } else {
            findViewById(R.id.zqr_legal_ll_bank).setVisibility(View.GONE);
//            findViewById(R.id.zqr_ll_bank).setVisibility(View.GONE);
        }
        if (identityBigTypes == TYPE_BIG_JG) {
            include_zqr_base_group.setVisibility(View.VISIBLE);
            findViewById(R.id.rg_zqr_czr_type_3).setVisibility(View.GONE);
            et_zqr_name.setHint("请填写公司或机构全称");
            if (identitySmallTypes == TYPE_SMALL_FDDBR) {

                tv_type.setText("机构债权人-法定代表人");
                ll_zqr_frsfzm.setVisibility(View.GONE);


                include_zqr_legal_person.setVisibility(View.VISIBLE);
                if (mType == 1) {
                    if (BankruptcyApp.loginInfo != null && BankruptcyApp.loginInfo.getLoginname() != null) {
                        et_zqr_fr_mobile.setText(BankruptcyApp.loginInfo.getLoginname());
                    }
                    et_zqr_fr_mobile.setEnabled(false);
                } else {
                    et_zqr_fr_mobile.setText(mZQUserInfo.getContact());
                    et_zqr_fr_mobile.setEnabled(false);
                }
            } else if (identitySmallTypes == TYPE_SMALL_DLR) {
                ll_zqr_frsfzm.setVisibility(View.VISIBLE);
                tv_type.setText("机构债权人-代理人");
//                ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(mZQUserInfo.getContact());
                if (mType == 1) {
                    if (BankruptcyApp.loginInfo != null && BankruptcyApp.loginInfo.getLoginname() != null) {
                        ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(BankruptcyApp.loginInfo.getLoginname());
                    }
                    ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setEnabled(false);
                } else {
                    et_zqr_dlr_mobile.setText(mZQUserInfo.getContact());
                    et_zqr_dlr_mobile.setEnabled(false);
                }
                include_zqr_dlr.setVisibility(View.VISIBLE);

            }
        }

        if (identityBigTypes == TYPE_BIG_ZRR) {
            et_zqr_name.setHint("请填写对破产企业有债权的个人姓名");
            if (identitySmallTypes == TYPE_SMALL_BR) {
                include_zqr_zrr_br.setVisibility(View.VISIBLE);
                tv_type.setText("自然人-本人");
//                ((TextView) findViewById(R.id.et_zqr_zrr_br_mobile)).setText(mZQUserInfo.getContact());
                if (mType == 1) {
                    if (BankruptcyApp.loginInfo != null && BankruptcyApp.loginInfo.getLoginname() != null) {
                        ((TextView) findViewById(R.id.et_zqr_zrr_br_mobile)).setText(BankruptcyApp.loginInfo.getLoginname());
                    }
                    ((TextView) findViewById(R.id.et_zqr_zrr_br_mobile)).setEnabled(false);
                } else {
                    et_zqr_zrr_br_mobile.setText(mZQUserInfo.getContact());
                    et_zqr_zrr_br_mobile.setEnabled(false);
                }
            } else if (identitySmallTypes == TYPE_SMALL_DLR) {
                tv_type.setText("自然人-代理人");
                zrr_zqrheadinfo.setVisibility(View.VISIBLE);
                include_zqr_dlr.setVisibility(View.VISIBLE);
//                ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(mZQUserInfo.getContact());
                if (mType == 1) {
                    if (BankruptcyApp.loginInfo != null && BankruptcyApp.loginInfo.getLoginname() != null) {
                        ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(BankruptcyApp.loginInfo.getLoginname());
                    }
                } else {
                    ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(mZQUserInfo.getContact());
                }
                ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setEnabled(false);
            }
        }

        if (identityBigTypes == TYPE_BIG_SW) {
            et_zqr_name.setHint("请填写对破产企业有债权的公司或其他机构的全称");
            tv_type.setText("税务机关");
            area_zqr_type_small.setVisibility(View.GONE);
//            ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(mZQUserInfo.getContact());
            include_zqr_dlr.setVisibility(View.VISIBLE);
            if (mType == 1) {
                if (BankruptcyApp.loginInfo != null && BankruptcyApp.loginInfo.getLoginname() != null) {
                    ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setText(BankruptcyApp.loginInfo.getLoginname());
                }
                ((TextView) findViewById(R.id.et_zqr_dlr_mobile)).setEnabled(false);
            } else {
                et_zqr_dlr_mobile.setText(mZQUserInfo.getContact());
                et_zqr_dlr_mobile.setEnabled(false);
            }
        }

    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
        findViewById(R.id.titlebar_back).performClick();
    }


    @Override
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.show_sfzm_temp1:
            case R.id.show_sfzm_temp2:

                TempleyActivity.start(EditZQUserBaseInfo_EditActivity.this, 1);
                break;
            case R.id.proxy_show_temp_xts:
                TempleyActivity.start(EditZQUserBaseInfo_EditActivity.this, 2);
                break;
            case R.id.tv_zqr_address:
                intent = new Intent(this, CreateAddrActivity.class);
                intent.putExtra(CreateAddrActivity.KEY_FROM, CreateAddrActivity.FROM_FLOW);
                if (mAddrInfo != null) {
                    MyAddr addr = new MyAddr();
                    addr =  new MyAddr().toMyArr(mZQUserInfo.getAddressInfo());
                    intent.putExtra(CreateAddrActivity.KEY_BEAN, addr);
                }
                startActivityForResult(intent, REQUEST_CODE_ADDRESS);
                break;
            case R.id.titlebar_menu_text:
                saveDataZ();


//                saveData();
                break;
            case R.id.titlebar_menu_text_zancun:
                opType = 1;
                saveData();
                break;
            case R.id.titlebar_back:
                mPromptDialog = new CommonPromptDialog(this, CommonPromptDialog.TYPE_TIPS);
                mPromptDialog.setTitle("放弃编辑？");
                mPromptDialog.setPositiveClickListener("是", view12 -> {
                    opType = 1;
                    mPromptDialog.dismiss();
                    finish();

//                    saveData();
                });
                mPromptDialog.setNegativeClickListener("否", view1 -> {
                    mPromptDialog.dismiss();

                });
                mPromptDialog.show();
//                    QQLogin();
                break;
            default:
                break;
        }
    }


    public void saveDataZ() {
        String creditorName = et_zqr_name.getText().toString();
        String socialUniformCreditCode = et_zqr_base_jg_social.getText().toString(); // 社会信用代码证
        String legalRepresentativeName = et_zqr_base_jg_legalname.getText().toString();//法定代表人姓名
        String otherContact = "";//其他联系方式
        String email = "";//邮箱
        String cardNumber = ""; //身份证号码
        String agentName = et_zqr_dlr_name.getText().toString(); //代理人姓名
        String agentLicenseNumber = et_zqr_dlr_sfz_zyz.getText().toString(); //代理人执业证号
        String creditorsIDCardNumber = et_zqr_dlr_sfz_zyz.getText().toString(); //代理人身份证号

        JSONArray cardFileJson = new JSONArray();
        JSONArray provideBusinessLicenseJson = new JSONArray();//营业执照附件
        JSONArray provideLegalRepresentativeJson = new JSONArray();//法定代表人身份证明附件
        JSONArray provideCardJson = new JSONArray();//身份证附件
        JSONArray provideCardZMJson = new JSONArray();//身份证附件
        JSONArray providePowerAttorneyJson = new JSONArray();//授权委托书附件
        JSONArray creditorsProvideCardJson = new JSONArray();

        int provideCard = 1;

        String bank = et_zqr_fr_bank.getText().toString();
        String bankBranch = et_zqr_fr_bankBranch.getText().toString();
        String bankAccountName = et_zqr_fr_bankAccountName.getText().toString();
        String bankAccount = et_zqr_fr_bankAccount.getText().toString();

//        if (TextUtils.isEmpty(creditorName) && identityBigTypes != 2) {
//            ToastUtil.showShort("债权人姓名不能为空");
//            return;
//        }

        // 两种不合法组合过滤
        if ((identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_BR) ||
                (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_FDDBR)) {
            ToastUtil.showShort("请选择操作人类型");
            return;
        }
        if (TextUtils.isEmpty(creditorName)) {
//                ToastUtil.showShort("债权人姓名不能为空");
            showToast("债权人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
            return;
        }
        // 机构-法人组合
        if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_FDDBR) {
            provideCard = provideCard1;
            cardNumber = et_zqr_fr_cardnum.getText().toString();
            email = et_zqr_fr_email.getText().toString();
            otherContact = et_zqr_fr_mobile_other.getText().toString();


            int num = 0;
            for (UploadImage image : mImgList_yyzz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideBusinessLicense == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传营业执照");
                showToast("请上传营业执照", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(legalRepresentativeName)) {
//                ToastUtil.showShort("法定代表人姓名不能为空");
                showToast("法定代表人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(legalRepresentativeName)) {
//                ToastUtil.showShort("法定代表人姓名不能为空");
                showToast("法定代表人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(cardNumber)) {
//                ToastUtil.showShort("法定代表人身份证号码不能为空");
                showToast("法定代表人身份证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            num = 0;
            for (UploadImage image : mImgList_frsfz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideCard1 == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传法人身份证");
                showToast("请上传法定代表人身份证", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            num = 0;
            for (UploadImage image : mImgList_frsfzm_zm) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideCardInt == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传法人身份证明");
                showToast("请上传法定代表人身份证明", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


        } else if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_DLR)
        {

            int num = 0;
            for (UploadImage image : mImgList_yyzz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideBusinessLicense == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传营业执照");
                showToast("请上传营业执照", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();

            if (TextUtils.isEmpty(legalRepresentativeName)) {
//                ToastUtil.showShort("代理人姓名不能为空");
                showToast("法定代表人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            num = 0;

            for (UploadImage image : mImgList_frsfzm2) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideCard1 == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传法人身份证");
                showToast("请上传法定代表人身份证明", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            if (TextUtils.isEmpty(agentName)) {
//                ToastUtil.showShort("代理人姓名不能为空");
                showToast("代理人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
                showToast("代理人身份证号或执业证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            num = 0;
            for (UploadImage image : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (creditorsProvideCard == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                showToast("请上传代理人身份证/执业证图片", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            provideCardInt = creditorsProvideCard;
            num = 0;
            for (UploadImage image : mImgList_dlr_sqwt) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (providePowerAttorney == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传授权委托文件");
                showToast("请上传授权委托文件", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


        } else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_BR) { // 自然人-本人组合
            provideCard = provideCard3;
            cardNumber = et_zqr_zrr_br_card.getText().toString();
            email = et_zqr_zrr_br_email.getText().toString();
            otherContact = et_zqr_zrr_br_mobile_other.getText().toString();

            if (TextUtils.isEmpty(cardNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
                showToast("身份证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            int num = 0;
            for (UploadImage image : mImgList_zrr_br_sfz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }

            if (provideCard == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传身份证图片");
                showToast("请上传身份证图片", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

//            int i=0;
//            for (UploadImage img : mImgList_zrr_br_sfz) {
//                if (TextUtils.equals(mImgList_zrr_br_sfz.get(i).getFilename(), NAME_ADD)) {
//                    continue;
//                }
//                JSONObject obj = new JSONObject();
//                try {
//                    obj.putOpt("attachmentName", "相关附件"+(i+1)+".jpg");
//                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
//                    obj.putOpt("attachmentSize", img.getFilesize());
//                    i++;
//                    provideCardJson.put(obj);
//                } catch (JSONException e) {
//                    e.printStackTrace();
//                }
//            }


        } else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_DLR) //本人代理人
        {


            cardNumber = zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card.getText().toString();
            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();


            if (TextUtils.isEmpty(cardNumber)) {
//                ToastUtil.showShort("代理人姓名不能为空");
                showToast("债权人身份证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            int num = 0;
            for (UploadImage image : mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num ++;
            }
            if (zqrLicense == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传授权委托文件");
                showToast("请上债权人身份证", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

//            if (zqrLicense == TYPE_UPLOAD && num == 0) {
////                ToastUtil.showShort("请上传法人身份证");
//                showToast("请上债权人身份证", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
//                return;
//            }

            provideCard = zqrLicense;
            int i = 0;
            for (UploadImage img : mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz) {
                if (TextUtils.equals(mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    cardFileJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }


            if (TextUtils.isEmpty(agentName)) {
//                ToastUtil.showShort("代理人姓名不能为空");
                showToast("代理人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
                showToast("代理人身份证号或执业证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            num = 0;
            for (UploadImage image : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (creditorsProvideCard == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                showToast("请上传代理人身份证/执业证图片", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


            num = 0;
            for (UploadImage image : mImgList_dlr_sqwt) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (providePowerAttorney == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传授权委托文件");
                showToast("请上传授权委托文件", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            i = 0;
            for (UploadImage img : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(mImgList_dlr_sfz_zyz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    creditorsProvideCardJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            i = 0;
            for (UploadImage img : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(mImgList_dlr_sfz_zyz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    providePowerAttorneyJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else { //  X-代理人组合
            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();


            if (TextUtils.isEmpty(agentName)) {
//                ToastUtil.showShort("代理人姓名不能为空");
                showToast("代理人姓名不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }
            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
                showToast("代理人身份证号或执业证号不能为空", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }

            int num = 0;
            for (UploadImage image : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (creditorsProvideCard == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                showToast("请上传代理人身份证/执业证图片", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


            num = 0;
            for (UploadImage image : mImgList_dlr_sqwt) {
                if (TextUtils.equals(image.getFilename(), NAME_ADD)) {
                    continue;
                }
                num++;
            }
            if (providePowerAttorney == TYPE_UPLOAD && num == 0) {
//                ToastUtil.showShort("请上传授权委托文件");
                showToast("请上传授权委托文件", com.linkage.seapeak.utils.ToastUtil.TOAST_TYPE.WARNING);
                return;
            }


        }

        if (0 == mType) {
            mPromptDialog = new CommonPromptDialog(this, CommonPromptDialog.TYPE_TIPS);
            mPromptDialog.setTitle("是否验证身份？");
            mPromptDialog.setPositiveClickListener("去验证", view12 -> {
                opType = 0;
                mPromptDialog.dismiss();
//                    finish();
                saveData();
            });
            mPromptDialog.setNegativeClickListener("暂存编辑", view1 -> {
                mPromptDialog.dismiss();
                opType = 1;
                saveData();
//                    finish();
            });
            mPromptDialog.show();
        } else {
            opType = 0;
            saveData();
        }
    }

    public void saveData() {
        String creditorName = et_zqr_name.getText().toString();
        String socialUniformCreditCode = et_zqr_base_jg_social.getText().toString(); // 社会信用代码证
        String legalRepresentativeName = et_zqr_base_jg_legalname.getText().toString();//法定代表人姓名
        String otherContact = "";//其他联系方式
        String email = "";//邮箱
        String cardNumber = ""; //身份证号码
        String agentName = et_zqr_dlr_name.getText().toString(); //代理人姓名
        String agentLicenseNumber = et_zqr_dlr_sfz_zyz.getText().toString(); //代理人执业证号
        String creditorsIDCardNumber = et_zqr_dlr_sfz_zyz.getText().toString(); //代理人身份证号

        JSONArray cardFileJson = new JSONArray();
        JSONArray provideBusinessLicenseJson = new JSONArray();//营业执照附件
        JSONArray provideLegalRepresentativeJson = new JSONArray();//法定代表人身份证明附件
        JSONArray provideCardJson = new JSONArray();//身份证附件
        JSONArray provideCardZMJson = new JSONArray();//身份证附件
        JSONArray providePowerAttorneyJson = new JSONArray();//授权委托书附件
        JSONArray creditorsProvideCardJson = new JSONArray();

        int provideCard = 0; //

        String bank = et_zqr_fr_bank.getText().toString();
        String bankBranch = et_zqr_fr_bankBranch.getText().toString();
        String bankAccountName = et_zqr_fr_bankAccountName.getText().toString();
        String bankAccount = et_zqr_fr_bankAccount.getText().toString();

        if (TextUtils.isEmpty(creditorName) && identityBigTypes != 2) {
            ToastUtil.showShort("债权人姓名不能为空");
            return;
        }

        // 两种不合法组合过滤
        if ((identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_BR) ||
                (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_FDDBR)) {
            ToastUtil.showShort("请选择操作人类型");
            return;
        }

        // 机构-法人组合
        if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_FDDBR) {
            provideCard = provideCard1;
            cardNumber = et_zqr_fr_cardnum.getText().toString();
            email = et_zqr_fr_email.getText().toString();
            otherContact = et_zqr_fr_mobile_other.getText().toString();

            if (provideBusinessLicense == TYPE_UPLOAD && mImgList_yyzz.size() == 0) {
                ToastUtil.showShort("请上传营业执照");
                return;
            }
//            if (provideLegalRepresentative == TYPE_UPLOAD && mImgList_frsfzm.size() == 0) {
//                ToastUtil.showShort("请上传法人身份证明");
//                return;
//            }
//
//            if (provideCard == TYPE_UPLOAD && mImgList_frsfz.size() == 0) {
//                ToastUtil.showShort("请上传法人身份证");
//                return;
//            }

//            if (TextUtils.isEmpty(socialUniformCreditCode)) {
//                ToastUtil.showShort("社会信用代码证不能为空");
//                return;
//            }
//            if (TextUtils.isEmpty(legalRepresentativeName)) {
//                ToastUtil.showShort("法定代表人姓名不能为空");
//                return;
//            }
//            if (TextUtils.isEmpty(cardNumber)) {
//                ToastUtil.showShort("法定代表人身份证号码不能为空");
//                return;
//            }

            int i = 0;
            for (UploadImage img : mImgList_yyzz) {
                if (TextUtils.equals(mImgList_yyzz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    i++;
                    provideBusinessLicenseJson.put(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }


            i = 0;
            for (UploadImage img : mImgList_frsfzm) {
                if (TextUtils.equals(mImgList_frsfzm.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    provideLegalRepresentativeJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            i = 0;
            for (UploadImage img : mImgList_frsfz) {
                if (TextUtils.equals(mImgList_frsfz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    i++;
                    provideCardJson.put(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            i = 0;
            for (UploadImage img : mImgList_frsfzm_zm) {
                if (TextUtils.equals(mImgList_frsfzm_zm.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    provideLegalRepresentativeJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else if (identityBigTypes == TYPE_BIG_JG && identitySmallTypes == TYPE_SMALL_DLR) {


//            bankBranch = et_zqr_proxy_bankBranch.getText().toString();
//            bankAccountName = et_zqr_proxy_bankAccountName.getText().toString();
//            bankAccount = et_zqr_proxy_bankAccount.getText().toString();
            if (provideBusinessLicense == TYPE_UPLOAD && mImgList_yyzz.size() == 0) {
                ToastUtil.showShort("请上传营业执照");
                return;
            }

            int i = 0;
            for (UploadImage img : mImgList_frsfzm2) {
                if (TextUtils.equals(mImgList_frsfzm2.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    provideLegalRepresentativeJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            i = 0;
            for (UploadImage img : mImgList_yyzz) {
                if (TextUtils.equals(mImgList_yyzz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    provideBusinessLicenseJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();

            if (TextUtils.isEmpty(agentName)) {
                ToastUtil.showShort("代理人姓名不能为空");
                return;
            }
//            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
//                return;
//            }

            if (creditorsProvideCard == TYPE_UPLOAD && mImgList_dlr_sfz_zyz.size() == 0) {
                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                return;
            }
            if (providePowerAttorney == TYPE_UPLOAD && mImgList_dlr_sqwt.size() == 0) {
                ToastUtil.showShort("请上传授权委托文件");
                return;
            }

            i = 0;
            for (UploadImage img : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(mImgList_dlr_sfz_zyz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    i++;
                    creditorsProvideCardJson.put(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            i = 0;
            for (UploadImage img : mImgList_dlr_sqwt) {
                if (TextUtils.equals(mImgList_dlr_sqwt.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    providePowerAttorneyJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_BR) { // 自然人-本人组合
            provideCard = provideCard3;
            cardNumber = et_zqr_zrr_br_card.getText().toString();
            email = et_zqr_zrr_br_email.getText().toString();
            otherContact = et_zqr_zrr_br_mobile_other.getText().toString();

            if (provideCard == TYPE_UPLOAD && mImgList_zrr_br_sfz.size() == 0) {
                ToastUtil.showShort("请上传身份证图片");
                return;
            }

            int i = 0;
            for (UploadImage img : mImgList_zrr_br_sfz) {
                if (TextUtils.equals(mImgList_zrr_br_sfz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    i++;
                    provideCardJson.put(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }


        } else if (identityBigTypes == TYPE_BIG_ZRR && identitySmallTypes == TYPE_SMALL_DLR) {


            cardNumber = zrr_zqrheadinfo_zrr_zqr_info_et_zqr_zrr_br_card.getText().toString();
            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();


            int i = 0;
            for (UploadImage img : mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz) {
                if (TextUtils.equals(mImgList_zrr_zqrheadinfo_recycler_imgs_zrr_br_sfz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    provideCardJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }


            if (TextUtils.isEmpty(agentName)) {
                ToastUtil.showShort("代理人姓名不能为空");
                return;
            }
//            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
//                return;
//            }
//            provideCard = creditorsProvideCard;
            provideCard = zqrLicense;
            if (creditorsProvideCard == TYPE_UPLOAD && mImgList_dlr_sfz_zyz.size() == 0) {
                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                return;
            }
            if (providePowerAttorney == TYPE_UPLOAD && mImgList_dlr_sqwt.size() == 0) {
                ToastUtil.showShort("请上传授权委托文件");
                return;
            }

            i = 0;
            for (UploadImage img : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(mImgList_dlr_sfz_zyz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    creditorsProvideCardJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            i = 0;
            for (UploadImage img : mImgList_dlr_sqwt) {
                if (TextUtils.equals(mImgList_dlr_sqwt.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    providePowerAttorneyJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else if (identityBigTypes == TYPE_BIG_SW) { //  X-代理人组合
            email = et_zqr_dlr_email.getText().toString();
            otherContact = et_zqr_dlr_mobile_other.getText().toString();

//            bankBranch = et_zqr_proxy_bankBranch.getText().toString();
//            bankAccountName = et_zqr_proxy_bankAccountName.getText().toString();
//            bankAccount = et_zqr_proxy_bankAccount.getText().toString();


            if (TextUtils.isEmpty(agentName)) {
                ToastUtil.showShort("代理人姓名不能为空");
                return;
            }
//            if (TextUtils.isEmpty(agentLicenseNumber)) {
//                ToastUtil.showShort("代理人身份证号或执业证号不能为空");
//                return;
//            }

            if (creditorsProvideCard == TYPE_UPLOAD && mImgList_dlr_sfz_zyz.size() == 0) {
                ToastUtil.showShort("请上传代理人身份证/执业证图片");
                return;
            }
            if (providePowerAttorney == TYPE_UPLOAD && mImgList_dlr_sqwt.size() == 0) {
                ToastUtil.showShort("请上传授权委托文件");
                return;
            }
            int i = 0;
            for (UploadImage img : mImgList_dlr_sfz_zyz) {
                if (TextUtils.equals(mImgList_dlr_sfz_zyz.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    i++;
                    creditorsProvideCardJson.put(obj);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            i = 0;
            for (UploadImage img : mImgList_dlr_sqwt) {
                if (TextUtils.equals(mImgList_dlr_sqwt.get(i).getFilename(), NAME_ADD)) {
                    continue;
                }
                JSONObject obj = new JSONObject();
                try {
                    obj.putOpt("attachmentName", "相关附件" + (i + 1) + ".jpg");
                    obj.putOpt("attachmentDownloadAddress", img.getFilepath());
                    obj.putOpt("attachmentSize", img.getFilesize());
                    providePowerAttorneyJson.put(obj);
                    i++;
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }


        mShapeLoadingDialog.setLoadingText("提交信息中...");
        mShapeLoadingDialog.setCanceledOnTouchOutside(false);
        mShapeLoadingDialog.show();

        Observable<JsonObject> observable;
//        if (mProTaskDetail != null) {
//            observable = Network
//                    .getAPIService()
//                    .editTask(getUserToken(), mProTaskDetail.getId(), mProTaskDetail.getBankruptcyProjectId(),
//                            taskName, taskDesc, selsysuserId,seluserId, mTime, fileArr.toString());
//        } else {


        if ("".equalsIgnoreCase(socialUniformCreditCode) && !"".equalsIgnoreCase(creditorsIDCardNumber)) {
            socialUniformCreditCode = creditorsIDCardNumber;
        }
        if ("".equalsIgnoreCase(cardNumber) && !"".equalsIgnoreCase(creditorsIDCardNumber)) {
            cardNumber = creditorsIDCardNumber;
        }
//            if("".equalsIgnoreCase(creditorName))
//            {
//                creditorName =
//            }

        String identitySmallTypes_str = "";
        if (identityBigTypes == 2) {
//            identitySmallTypes = -1;
            identitySmallTypes_str = "null";
        } else {
            identitySmallTypes_str = identitySmallTypes + "";
        }
        observable = Network
                .getAPIService()
                .createCreditorInfo(
                        getUserToken(),
                        mZQUserInfo.getBankruptcyProjectId(),
                        mZQUserInfo.getId(),
                        identityBigTypes,
                        identitySmallTypes_str,
                        creditorName,
                        provideBusinessLicense,
                        socialUniformCreditCode,
                        legalRepresentativeName,
                        otherContact,
                        email,
                        provideCard,
                        cardNumber,
                        provideLegalRepresentative,
                        sysAddressId,
                        agentName,
                        creditorsProvideCard,
                        providePowerAttorney,
                        agentLicenseNumber,
                        creditorsIDCardNumber,
                        provideBusinessLicenseJson.toString(),
                        provideLegalRepresentativeJson.toString(),
                        provideCardJson.toString(),
                        providePowerAttorneyJson.toString(),
                        creditorsProvideCardJson.toString(),
                        bank,
                        bankBranch,
                        bankAccountName,
                        bankAccount,
                        opType,
                        mType,
                        cardFileJson.toString(),
                        provideCardInt + ""
                );


//        }

        observable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        mShapeLoadingDialog.dismiss();
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            super.onNext(json);
                            return;
                        }
                        RefreshEvent event = new RefreshEvent();
                        event.setType(RefreshEvent.TYPE_ZQR);
                        EventBus.getDefault().post(event);

                        if (0 == mType) {
                            ToastUtil.showShort("提交成功");

                            finish();
                        } else {

                            if (opType == 0) {
                                makesureDialog = new PublicNoticeDialog(EditZQUserBaseInfo_EditActivity.this, new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {


                                        makesureDialog.dismiss();
                                        finish();
//                                    }
                                    }
                                }, 5, "提示", "提交成功，等待管理人审核", "取消", "我知道了");
                                makesureDialog.show();
                            } else {
                                ToastUtil.showShort("暂存成功");

                                finish();
                            }
                        }
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        mShapeLoadingDialog.dismiss();
                        super.onError(e);
                    }
                });
    }

    private PublicNoticeDialog makesureDialog;


    public void getData() {
        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
            return;
        }
//        shapeLoadingDialog.setLoadingText("加载中...");
//        shapeLoadingDialog.setCanceledOnTouchOutside(false);
//        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
//        HashMap<String, String> params = new HashMap<String, String>();
        Random random = new Random();
        String rom = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        String userId = SPUtils.getInstance(Consts.SPNAME).getString("userId", "");


        RequestBody requestBody = new FormBody.Builder()
                .add("appid", "1000000001")
                .add("nonce", rom)
                .add("timestamp", timestamp)

                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken", userToken)

                .add("creditorId", mZQUserInfo.getId())
                .add("projectId", mZQUserInfo.getBankruptcyProjectId())
                .add("type", "1")

                .build();

        String url = Consts.WEBURL_CREDITORINFO;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {


                String str = response.body().string();
                try {


                    JSONObject object = new JSONObject(str);
                    if (object.optInt("code") == 0) {
                        JSONObject dataobj = object.getJSONObject("data");
//                        JSONObject groupListobj = dataobj.getJSONObject("groupList");
//                        Iterator<String> it = groupListobj.keys();
                        List<ManagerUserInfo> list = new ArrayList<>();
                        Gson gson = new Gson();

                        ZQUserDetailBaseInfo info = gson.fromJson(dataobj.optString("creditorInfo"), ZQUserDetailBaseInfo.class);

                        if (info != null) {
                            runOnUiThread(new Runnable() {

                                @Override
                                public void run() {
                                    et_zqr_name.setText(info.getCreditorName());
                                }

                            });

                        }

                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
    }

    public void getProjetContact() {

        Observable<JsonObject> observable;

        observable = Network
                .getAPIService()
                .getProjetContact(getUserToken(),mZQUserInfo.getBankruptcyProjectId());


        observable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {

                        int code = json.get("code").getAsInt();

                        if(code == 0)
                        {
                            ContactInfo info = new Gson().fromJson(json.getAsJsonObject("data"),ContactInfo.class);
                            if(info!=null)
                                QuickUserPopView.show(EditZQUserBaseInfo_EditActivity.this,info.getSysUserId(),mZQUserInfo.getBankruptcyProjectId(),info.getName(),info.getMobile());
                        }else
                        {
                            ToastUtil.showShort(json.get("msg").getAsString());

                        }
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {

                        super.onError(e);
                    }
                });
    }
}